﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Text;

using Oracle.ManagedDataAccess.Client;

namespace WFL.Data.Oracle
{
    public class OracleOperationWithContext : OracleOperation
    {
        private static Context _defaultContext = new OracleContext();

        public Context Context
        {
            get;
            set;
        }

        public OracleOperationWithContext()
            : this(null)
        {

        }

        public OracleOperationWithContext(string connectionString)
            : base(connectionString)
        {
            Context = _defaultContext;
        }

        protected override OracleConnection GetContextConnection()
        {
            OracleConnectionProxy connProxy = Context.GetConn() as OracleConnectionProxy;
            return connProxy != null ? connProxy.Connection : null;
        }

        protected override OracleTransaction GetContextTransaction()
        {
            OracleConnectionProxy connProxy = Context.GetConn() as OracleConnectionProxy;
            if (connProxy != null
                && connProxy.TransactionProxy != null)
            {
                return connProxy.TransactionProxy.Transaction;
            }
            return null;
        }


    }
}
